<?php
$name=$_POST["name"];
$text=$_POST["text"];
//定位东八区的时间
date_default_timezone_set("PRC");

//$add = date("Y-m-d H:i:s",1616406646);
//$update = date("Y-m-d H:i:s",1616406646);
$time = time();


$dsn = "mysql:host=127.0.0.1;dbname=blog";
$db = new PDO($dsn,"root","123456");
//设计字符集
$db->exec("set names utf8mb4");
$sql = "INSERT into category (category_name,category_desc,update_time,add_time)
 VALUES('$name','$text','$time ','$time ')";
$result = $db->exec($sql);

if($result){
    echo "插入成功";
    echo "<a href='category.php'>点击返回列表页面</a>";
    exit();
}else{
    echo "插入失败，错误信息".$db->errorInfo()[2]."请联系管理员";
    echo "<a href='category.php'>点击返回列表页面</a>";
}